const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('electronAPI', {
  selectSavePath: (defaultName) => ipcRenderer.invoke('dialog:selectSavePath', defaultName),
  selectDirectory: () => ipcRenderer.invoke('dialog:selectDirectory'),
  
  startDownload: (config) => ipcRenderer.invoke('download:start', config),
  pauseDownload: (id) => ipcRenderer.invoke('download:pause', id),
  resumeDownload: (id) => ipcRenderer.invoke('download:resume', id),
  cancelDownload: (id) => ipcRenderer.invoke('download:cancel', id),
  parseLink: (link) => ipcRenderer.invoke('download:parseLink', link),
  
  onDownloadProgress: (callback) => {
    ipcRenderer.on('download:progress', (event, data) => callback(data));
  },
  onDownloadComplete: (callback) => {
    ipcRenderer.on('download:complete', (event, data) => callback(data));
  },
  onDownloadError: (callback) => {
    ipcRenderer.on('download:error', (event, data) => callback(data));
  }
});

